package genericdemo;

class Food{

}
class Fruit extends Food{

}
class Apple extends Fruit{

}
class Banana extends Fruit{

}

class Plate<T>{
    private T message;

    public T getPlate(){
        return message;
    }

    public void setPlate(T message){
        this.message = message;
    }
}

public class TestDemo5 {

    public static void main(String[] args) {
        Plate<Apple> plate1 = new Plate<>();
        Plate<Banana> plate2 = new Plate<>();
        fun1(plate1);
        fun1(plate2);
    }

    //通配符的上界 一般用来读取元素
    public static void fun1(Plate<? extends Fruit> temp){
        //temp.setPlate(new Apple());//为啥这里报错


        System.out.println(temp.getPlate());
    }

}
